package com.zretc.controller;

import com.zretc.entity.Type;
import com.zretc.service.TypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@CrossOrigin
@RequestMapping("/type")
public class TypeController {
    @Autowired
    private TypeService typeService;

    @RequestMapping("/types")
    @ResponseBody
    public List<Type> findAll(){
        List<Type> types = typeService.getAllType();
        return types;
    }

    @RequestMapping("/getTypeName")
    @ResponseBody
    public List<Type> getTypeName(@RequestParam(value = "sellerAccount") String sellerAccount){
        List<Type> types = typeService.getTypeBySellerAccount(sellerAccount);
        return types;
    }

}
